import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:jet_rails/jr_app/jr_models/jr_user_model.dart';
import 'package:jet_rails/jr_app/jr_widgets/jr_avatar.dart';

class JrUserTile extends StatefulWidget {
  final JrUserModel user;
  final Widget? action;
  const JrUserTile({Key? key, required this.user, this.action}) : super(key: key);

  @override
  State<JrUserTile> createState() => _JrUserTileState();
}

class _JrUserTileState extends State<JrUserTile> {
  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        JrAvatar(
          url: widget.user.getAvatarUrl,
          size: 44.r,
        ),
        SizedBox(width: 10.w),
        Expanded(
            child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              widget.user.nickname ?? '',
              style: TextStyle(color: Colors.white, fontSize: 14.sp),
              maxLines: 2,
              overflow: TextOverflow.ellipsis,
            ),
            Text(
              '${widget.user.age ?? ''} ${widget.user.country ?? ''}',
              style: TextStyle(color: Colors.white60, fontSize: 12.sp),
            )
          ],
        )),
        widget.action ?? Container()
      ],
    );
  }
}
